﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace SeniorEventExampleInputManager
{
    class MyArgs
    {
        public char input;
    }
    class InputManager
    {
        public event EventHandler<MyArgs> OnInput=null;
        public void WaitForInput()
        {
            MyArgs args = new MyArgs();
            while (true)
            {
                char input =  Convert.ToChar(Console.Read());
                if (OnInput != null) 
                { 
                    args.input = input;
                    OnInput(this, args);
                }
            }
        }

    }
    internal class Program
    {
        public static void OnKeyInput(object o, MyArgs args)
        {
            Console.WriteLine(args.input);
            Console.WriteLine("键盘输入事件被监听到了"+o);
        }
        static void Main(string[] args)
        {
            InputManager im = new InputManager();
            im.OnInput += OnKeyInput;
            im.WaitForInput();
        }
    }
}
